import KoaRouter from 'koa-router';
import { Controller, Request } from './../../decorators/router.decorator';

@Controller({ prefix: '/clusters' })
export default class ClusterController {

    @Request({ url: '/', method: 'get' })
    async clusters(ctx: any) {
        ctx.body = { code: '0', data: [] };
    }

    @Request({ url: '/detail', method: 'get' })
    async clusterDetail(ctx: any) {
        await ctx.render('index', {
            title: ctx.query.name,
            // namespaces: ['clusters']
        });
    }

    cluDetail(router: KoaRouter) {
        return router.get(`/detail/demo`, async (ctx, next) => {
            const name = ctx.query.name;
            ctx.response.type = 'application/json';
            ctx.response.body = { code: 200, data: [{ clusterName: 'cluster-name' + name, status: 'Healthy' }] };
        });
    }
}

